< previous page page_421 next page >

Page 421
Working with ODBC Results Using the ODBC API to handle information in the database can become complex. If you didn't understand the operations of cursors before, the ODBC API isn't going to give you much comfort. Nonetheless, you need to firmly understand how to work with cursors and how to modify your resultsets. For every SQL command you send to the database via the ODBC API, you must work with the resultset(s) subsequently generated, regardless of whether the resultset contains any records. Because you use a statement handle (hStmt) for each resultset, you must process the rows in them before using that statement handle again.
With regard to the ODBC API, your use of the SELECT statement in a query results in a cursor being associated with that query. To apply a name to that cursor, use the SQLSetCursorName. At times you might need to configure certain information regarding resultset columns. Use the ODBC functions SQLDescribeCol, SQLColAttributes, and SQLNumResultCol to determine the characteristics of the resultset. In the ODBCResultset class, you would have the following method:
Public Sub configureAttributes(ParamArray argAttribs())
The ParamArray argument, argAttribs(), gives you the flexibility to send in a varying number of arguments that contain attribute values for the three ODBC functions.
The ODBCResultset class would also have the following method for working with results:
Public Sub openDBResultset()
The openDBResultset method uses any number of the following ODBC API functions to get data from the data source and into Visual Basic variables:
SQLBindCol
SQLFetch
SQLExtendedFetch
SQLGetData
SQLBindCol assigns a variable to one or more selected columns that make up the resultset. You place data into the desired variable with either the SQLFetch or SQLExtendedFetch function. The SQLGetData function fetches character data from a specific column into a Visual Basic string variable. SQLGetNumericData obtains non-String data from a specific column in the data source and assigns it to a Visual Basic variable. To set the column attributes for each column, pass in the appropriate function arguments of the relevant ODBC function.

 
< previous page page_421 next page >

If you like this book, buy it!